define([
    "UtilDir/util",
    "UtilDir/tool",
    "UtilDir/combotree",
    "UtilDir/dialog",
    "UtilDir/searchBlock",
    "HomeDir/js/router",
    "HomeDir/js/tabs",
    "static/app/fwsjcj/chinaMap/echarts",
    "static/app/fwsjcj/chinaMap/circleChart",
    "static/app/fwsjcj/chinaMap/china",
    "static/app/fwsjcj/chinaMap/province/anhui",
    "static/app/fwsjcj/chinaMap/province/aomen",
    "static/app/fwsjcj/chinaMap/province/beijing",
    "static/app/fwsjcj/chinaMap/province/chongqing",
    "static/app/fwsjcj/chinaMap/province/fujian",
    "static/app/fwsjcj/chinaMap/province/gansu",
    "static/app/fwsjcj/chinaMap/province/guangdong",
    "static/app/fwsjcj/chinaMap/province/guangxi",
    "static/app/fwsjcj/chinaMap/province/guizhou",
    "static/app/fwsjcj/chinaMap/province/hainan",
    "static/app/fwsjcj/chinaMap/province/hebei",
    "static/app/fwsjcj/chinaMap/province/heilongjiang",
    "static/app/fwsjcj/chinaMap/province/henan",
    "static/app/fwsjcj/chinaMap/province/hubei",
    "static/app/fwsjcj/chinaMap/province/hunan",
    "static/app/fwsjcj/chinaMap/province/jiangsu",
    "static/app/fwsjcj/chinaMap/province/jiangxi",
    "static/app/fwsjcj/chinaMap/province/jilin",
    "static/app/fwsjcj/chinaMap/province/liaoning",
    "static/app/fwsjcj/chinaMap/province/neimenggu",
    "static/app/fwsjcj/chinaMap/province/ningxia",
    "static/app/fwsjcj/chinaMap/province/qinghai",
    "static/app/fwsjcj/chinaMap/province/shandong",
    "static/app/fwsjcj/chinaMap/province/shanghai",
    "static/app/fwsjcj/chinaMap/province/shanxi",
    "static/app/fwsjcj/chinaMap/province/shanxi1",
    "static/app/fwsjcj/chinaMap/province/sichuan",
    "static/app/fwsjcj/chinaMap/province/taiwan",
    "static/app/fwsjcj/chinaMap/province/tianjin",
    "static/app/fwsjcj/chinaMap/province/xianggang",
    "static/app/fwsjcj/chinaMap/province/xinjiang",
    "static/app/fwsjcj/chinaMap/province/xizang",
    "static/app/fwsjcj/chinaMap/province/yunnan",
    "static/app/fwsjcj/chinaMap/province/zhejiang",
    "static/app/fwsjcj/chinaMap/city",
    "EasyUI", "EasyUI-lang",
    "css!static/app/fwsjcj/chinaMap/normalize",
    "css!static/app/fwsjcj/chinaMap/htmleaf-demo",
], function (Util, Tool, Combotree, Dialog, SearchBlock, Router, Tabs, echarts) {

    var sysPath = getServer() + "/static/app/fwsjcj";
    var auditFormHtml = sysPath + "/censusdata/views/censusForm.html";
    var getCmController = function () {
        return getServer() + "/fw/";
    };
    var getDivisionController = function () {
        return getServer() + "/platform/org/divisions/";
    };
    /**
     * 页面初始化
     */
    var init = function () {
        initSearchBlock();
        queryBtnBind();
        //initDivision();
        initSearchForm();
        chinaMap();
        clickTabs();
        getStructure();
        createAreaGrid();        
        createNumsGrid();
        getProvince();
    };

    var initSearchBlock = function (flag,province) {
    	if(flag == 1){
    		$(".circleChart#p0").show();
    		$(".circleChart#p1").show();
    		$(".circleChart#p2").show();
    		$(".circleChart#p3").show();
    		$(".circleChart#0").hide();
    		$(".circleChart#1").hide();
    		$(".circleChart#2").hide();
    		$(".circleChart#3").hide();
    		
    		$.ajax({
	            url: getCmController() + "division/provinceFwData",
	            contentType: "application/json",
	            type: "get",
	            data:{
	            	province:province
	            },
	            success: function (data) {
	              	console.log(data)
	//              debugger
					var textTitle = "";
	                $("#qgArea").text(data[0].areaData);
	                $("#qgAreaSampling").text(data[0].areaSampling);
	                $("#qgCount").text(data[0].countData);
	                $("#qgCountSampling").text(data[0].countSampling);
	                var areaSampling = data[0].areaSampling.substr(0,data[0].areaSampling.length-1);
	                var countSampling = data[0].countSampling.substr(0,data[0].countSampling.length-1);
	                
	                $(".circleChart#p0").circleChart({
			    		color:"#107ce5",
			            size: 110,
			            value: areaSampling,
			            lineCap:"square",
			            text: "全省面积\n（万平方米）",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
			        $(".circleChart#p1").circleChart({
			        	color:"#107ce5",
			            size: 110,
			            value: areaSampling,
			            lineCap:"square",
			            text: "面积\n抽样率",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
			        $(".circleChart#p2").circleChart({
			    		color:"#28c99d",
			            size: 110,
			            value: countSampling,
			            lineCap:"square",
			            text: "全省栋数\n（栋）",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
			        $(".circleChart#p3").circleChart({
			    		color:"#28c99d",
			            size: 110,
			            value: countSampling,
			            lineCap:"square",
			            text: "栋数\n抽样率",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
	                
	            }
	       	})
    		
    	}else{
    		$(".circleChart#0").show();
    		$(".circleChart#1").show();
    		$(".circleChart#2").show();
    		$(".circleChart#3").show();
    		$(".circleChart#p0").hide();
    		$(".circleChart#p1").hide();
    		$(".circleChart#p2").hide();
    		$(".circleChart#p3").hide();
    	
	    	$.ajax({
	            url: getCmController() + "chinaData",
	            contentType: "application/json",
	            type: "get",
	            success: function (data) {
	//              console.log(data)
	//              debugger
					var textTitle = "";
	                $("#qgArea").text(data[0].areaData);
	                $("#qgAreaSampling").text(data[0].areaSampling);
	                $("#qgCount").text(data[0].countData);
	                $("#qgCountSampling").text(data[0].countSampling);
	                var areaSampling = data[0].areaSampling.substr(0,data[0].areaSampling.length-1);
	                var countSampling = data[0].countSampling.substr(0,data[0].countSampling.length-1);
	
	                $(".circleChart#0").circleChart({
			    		color:"#107ce5",
			            size: 110,
			            value: areaSampling,
			            lineCap:"square",
			            text: "全国面积\n（万平方米）",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
			        $(".circleChart#1").circleChart({
			        	color:"#107ce5",
			            size: 110,
			            value: areaSampling,
			            lineCap:"square",
			            text: "面积\n抽样率",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
			        $(".circleChart#2").circleChart({
			    		color:"#28c99d",
			            size: 110,
			            value: countSampling,
			            lineCap:"square",
			            text: "全国栋数\n（栋）",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
			        $(".circleChart#3").circleChart({
			    		color:"#28c99d",
			            size: 110,
			            value: countSampling,
			            lineCap:"square",
			            text: "栋数\n抽样率",
			            textCenter: true,
			            counterclockwise:true,
			            startAngle:25,
			            textSize:"15px",
			           	onDraw: function(el, circle) {
			               	$("p.circleChart_text", el).css({
				                "position": "absolute",
				                "line-height": "20px",
				                "top": 36,
				                "width": "100%",
				                "margin": 0,
				                "padding": 0,
				                 "white-space": "pre-wrap",
			              	});
			           	}
			        });
	            }
	        });	
    	}
        
    };
    // 查询
    var queryBtnBind = function () {
    	$("#backBtn1").click(function () {
            $("#main").show();
            $("#province").hide();
            $("#city").hide();
            $("#right-top").hide();
            $("#backBtn1").hide();
            $("#selectProvince").hide();
            $("#belongtoProvince").val("");
            $(".right-main-title").text("各省(直辖市)已提交房屋数据统计");
            $(".main-title").text("各省(直辖市)已提交面积区划地图");
            createAreaGrid();
            createNumsGrid();
            initSearchBlock();
            getStructure();
    	});
    	$("#backBtn2").click(function () {
            $("#main").hide();
            $("#province").show();
            $("#city").hide();
            $("#backBtn2").hide();
            $("#backBtn1").show();
    	});
		
    };
    var getProvince = function () {
    	var html = "";
        $.ajax({
            url: "/app/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                //console.log(data);
                $.each(data, function (idx, item) {
                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#belongtoProvince").append(html);
            }
        });
        // 点击省
        $("#belongtoProvince").change(function () {
            let divisionId = $(this).find("option:selected").attr("exid");
            let divisionName = $(this).find("option:selected").attr("value");           
//          console.log(divisionId);
//          console.log(divisionName);
            if(divisionName=="内蒙古自治区"||divisionName=="黑龙江省"){
            	provinceMap(divisionName.substring(0,3),divisionName);
            }else{
            	provinceMap(divisionName.substring(0,2),divisionName);
            }
            $(".right-main-title").text(divisionName + "已提交房屋数据统计");
            $(".main-title").text(divisionName + "已提交面积区划地图");
            initSearchBlock(1,divisionName);
            getStructure(1,divisionName);
            createAreaGrid(1,divisionName);
            createNumsGrid(1,divisionName);
            
        });
    }
    var dataArea = [
	    {
	    	province:"北京市",
	    	area:"151.07",
	    	rate:"1.89%"
	    },{
	    	province:"天津市",
	    	area:"151.07",
	    	rate:"1.89%"
	    },{
	    	province:"河北省",
	    	area:"151.07",
	    	rate:"1.89%"
	    },{
	    	province:"山西省",
	    	area:"151.07",
	    	rate:"1.89%"
	    }
	];
	var dataNums = [
	    {
	    	province:"北京市",
	    	nums:"151",
	    	rate:"1.89%"
	    },{
	    	province:"天津市",
	    	nums:"151",
	    	rate:"1.89%"
	    },{
	    	province:"河北省",
	    	nums:"151",
	    	rate:"1.89%"
	    },{
	    	province:"山西省",
	    	nums:"151",
	    	rate:"1.89%"
	    }
	];
	var getStructure = function (flag,province) {
		var ajaxUrl; 
		var province = province;
		
		if(flag == 1){
			ajaxUrl = "division/provinceStructureData"
			province = province;
		}else{
			ajaxUrl = "structureData"
			province = "";
			
		}
		$.ajax({
            url: getCmController() + ajaxUrl,
            contentType: "application/json",
            type: "get",
            data:{
            	province:province
            },
            success: function (data) {
                console.log(data)
                for(var i=0;i<data.length;i++){
                	if(data[i].structureName=="砖混结构"){
	                	$("#brickArea").text(data[i].structureAreaData);
	                	$("#brickAreaSampling").text(data[i].structureAreaProportion);
	                	$("#brickAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#brickCount").text(data[i].structureCountData);
	                	$("#brickCountSampling").text(data[i].structureCountProportion);
	                	$("#brickCountProgress").css("width",data[i].structureCountProportion);
	                }else if(data[i].structureName=="多层钢筋混凝土结构"){
	                	$("#concreteArea").text(data[i].structureAreaData);
	                	$("#concreteAreaSampling").text(data[i].structureAreaProportion);
	                	$("#concreteAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#concreteCount").text(data[i].structureCountData);
	                	$("#concreteCountSampling").text(data[i].structureCountProportion);
	                	$("#concreteCountProgress").css("width",data[i].structureCountProportion);	                	                	
	                	
	                }else if(data[i].structureName=="高层结构"){
	                	$("#highStructureArea").text(data[i].structureAreaData);
	                	$("#highStructureAreaSampling").text(data[i].structureAreaProportion);
	                	$("#highStructureAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#highStructureCount").text(data[i].structureCountData);
	                	$("#highStructureCountSampling").text(data[i].structureCountProportion);
	                	$("#highStructureCountProgress").css("width",data[i].structureCountProportion);
	                	
	                }else if(data[i].structureName=="工业厂房结构"){
	                	$("#factoryArea").text(data[i].structureAreaData);
	                	$("#factoryAreaSampling").text(data[i].structureAreaProportion);
	                	$("#factoryAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#factoryCount").text(data[i].structureCountData);
	                	$("#factoryCountSampling").text(data[i].structureCountProportion);
	                	$("#factoryCountProgress").css("width",data[i].structureCountProportion);
	                
	                	
	                }else if(data[i].structureName=="空旷结构"){
	                	$("#wideStructureArea").text(data[i].structureAreaData);
	                	$("#wideStructureAreaSampling").text(data[i].structureAreaProportion);
	                	$("#wideStructureAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#wideStructureCount").text(data[i].structureCountData);
	                	$("#wideStructureCountSampling").text(data[i].structureCountProportion);
	                	$("#wideStructureCountProgress").css("width",data[i].structureCountProportion);
	                
	                	
	                }else if(data[i].structureName=="土木结构"){
	                	$("#buildingArea").text(data[i].structureAreaData);
	                	$("#buildingAreaSampling").text(data[i].structureAreaProportion);
	                	$("#buildingAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#buildingCount").text(data[i].structureCountData);
	                	$("#buildingCountSampling").text(data[i].structureCountProportion);
	                	$("#buildingCountProgress").css("width",data[i].structureCountProportion);
	                
	                	
	                }else if(data[i].structureName=="木结构"){
	                	$("#woodArea").text(data[i].structureAreaData);
	                	$("#woodAreaSampling").text(data[i].structureAreaProportion);
	                	$("#woodAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#woodCount").text(data[i].structureCountData);
	                	$("#woodCountSampling").text(data[i].structureCountProportion);
	                	$("#woodCountProgress").css("width",data[i].structureCountProportion);
	                
	                	
	                }else if(data[i].structureName=="石结构"){
	                	$("#stoneArea").text(data[i].structureAreaData);
	                	$("#stoneAreaSampling").text(data[i].structureAreaProportion);
	                	$("#stoneAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#stoneCount").text(data[i].structureCountData);
	                	$("#stoneCountSampling").text(data[i].structureCountProportion);
	                	$("#stoneCountProgress").css("width",data[i].structureCountProportion);
	                
	                	
	                }else if(data[i].structureName=="其他"){
	                	$("#otherArea").text(data[i].structureAreaData);
	                	$("#otherAreaSampling").text(data[i].structureAreaProportion);
	                	$("#otherAreaProgress").css("width",data[i].structureAreaProportion);
	                	$("#otherCount").text(data[i].structureCountData);
	                	$("#otherCountSampling").text(data[i].structureCountProportion);
	                	$("#otherCountProgress").css("width",data[i].structureCountProportion);
	                	                	
	                }else if(data[i].structureName=="砖木结构"){
                        $("#brickwoodArea").text(data[i].structureAreaData);
                        $("#brickwoodAreaSampling").text(data[i].structureAreaProportion);
                        $("#brickwoodAreaProgress").css("width",data[i].structureAreaProportion);
                        $("#brickwoodCount").text(data[i].structureCountData);
                        $("#brickwoodCountSampling").text(data[i].structureCountProportion);
                        $("#brickwoodCountProgress").css("width",data[i].structureCountProportion);
                    }
                }              
                
            }
        });
	}
	var clickTabs = function () {
//		$('#myTabStructure').on('shown.bs.tab', function (e) {
//          var tabid = $(e.target).attr('id');
//          if (tabid == 'areaStructurelab') {
//				getStructure();
//          } else if (tabid == 'numsStructurelab') {
//				getStructure();
//          } 
//
//      })
        $('#myTabTable').on('shown.bs.tab', function (e) {
            var tabid = $(e.target).attr('id');
            var belongtoProvince = $("#belongtoProvince").val();
            if (tabid == 'areaTablelab') {
            	if(belongtoProvince!=""){
            		createAreaGrid(1,belongtoProvince);
            	}else{
            		createAreaGrid();
            	}
				
            } else if (tabid == 'numsTablelab') {
            	if(belongtoProvince!=""){
            		createNumsGrid(1,belongtoProvince);
            	}else{
            		createNumsGrid();
            	}
				
            } 

        })
    }
    var createAreaGrid = function (flag,province) {
    	if(flag==1){
    		$("#areaGrid").datagrid({
	            url: getCmController() + "division/cityFwData",
	            method: "GET",
	            nowrap: false,
	            striped:true,
	            columns: [
	                [
	                    {
	                        field: 'belongtoCity',
	                        title: '市/区',
	                        width: '40%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'areaData',
	                        title: '面积(万平方米)',
	                        width: '36%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'areaSampling',
	                        title: '抽样率',
	                        width: '30%',
	                        align: 'center'
	                    },
	
	                ]
	            ],
	            rowStyler: function(index, row) {
			         //index:下标   row对象
			        //此处可以添加条件
			        if(index % 2 != 0){
			            // return 'background-color:red;';
			            return 'background-color:#f5f9fe;';
			        }
			    },
	            //data:dataArea
	          	queryParams: {
              		province: province,
	          	},
	//          pagination: true,
	//          pageSize: 10
	        });
    	}else{
	        $("#areaGrid").datagrid({
	            url: getCmController() + "provinceData",
	            method: "GET",
	            nowrap: false,
	            striped:true,
	            columns: [
	                [
	                    {
	                        field: 'districtName',
	                        title: '省(直辖市)',
	                        width: '40%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'areaData',
	                        title: '面积(万平方米)',
	                        width: '36%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'areaSampling',
	                        title: '抽样率',
	                        width: '30%',
	                        align: 'center'
	                    },
	
	                ]
	            ],
	            rowStyler: function(index, row) {
			         //index:下标   row对象
			        //此处可以添加条件
			        if(index % 2 != 0){
			            // return 'background-color:red;';
			            return 'background-color:#f5f9fe;';
			        }
			    },
	            //data:dataArea
	//          queryParams: {
	//              status: $("#status").val(),
	//              taskName: $("#taskName").val(),
	//          },
	//          pagination: true,
	//          pageSize: 10
	        });
        }
    };
    var createNumsGrid = function (flag,province) {
    	if(flag==1){
    		$("#numsGrid").datagrid({
	            url: getCmController() + "division/cityFwData",
	            method: "GET",
	            nowrap: false,
	            striped:true,
	            columns: [
	                [
	                    {
	                        field: 'belongtoCity',
	                        title: '市/区',
	                        width: '40%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'countData',
	                        title: '栋数(栋)',
	                        width: '36%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'countSampling',
	                        title: '抽样率',
	                        width: '30%',
	                        align: 'center'
	                    },
	
	                ]
	            ],
	            rowStyler: function(index, row) {
			         //index:下标   row对象
			        //此处可以添加条件
			        if(index % 2 != 0){
			            // return 'background-color:red;';
			            return 'background-color:#f5f9fe;';
			        }
			    },
	            //data:dataNums
	          	queryParams: {
	              	province: province,
	          	},
	//          pagination: true,
	//          pageSize: 10
			});
    	}else{
    		  	
	        $("#numsGrid").datagrid({
	            url: getCmController() + "provinceData",
	            method: "GET",
	            nowrap: false,
	            striped:true,
	            columns: [
	                [
	                    {
	                        field: 'districtName',
	                        title: '省(直辖市)',
	                        width: '40%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'countData',
	                        title: '栋数(栋)',
	                        width: '36%',
	                        align: 'center'
	                    },
	                    {
	                        field: 'countSampling',
	                        title: '抽样率',
	                        width: '30%',
	                        align: 'center'
	                    },
	
	                ]
	            ],
	            rowStyler: function(index, row) {
			         //index:下标   row对象
			        //此处可以添加条件
			        if(index % 2 != 0){
			            // return 'background-color:red;';
			            return 'background-color:#f5f9fe;';
			        }
			    },
	            //data:dataNums
	//          queryParams: {
	//              status: $("#status").val(),
	//              taskName: $("#taskName").val(),
	//          },
	//          pagination: true,
	//          pageSize: 10
	        });
	    }
    };
    var randomValue = function () {
        return Math.round(Math.random()*1000);
    }
	var chinaMap = function () {
		var dataList;
		$.ajax({
            url: getCmController() + "chinaProvinceData",
            contentType: "application/json",
            type: "get",
            async: false,
            success: function (data) {
                console.log(data)
                dataList = data;
            }
        })
//      var dataList=[
//          //{name:"南海诸岛",value:0},
//          {name: '北京', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '天津', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '上海', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '重庆', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '河北', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '河南', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '云南', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '辽宁', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '黑龙江', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '湖南', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '安徽', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '山东', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '新疆', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '江苏', value: randomValue(),areaSampling: "78.96%",countSampling:"55.35%"},
//          {name: '浙江', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '江西', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '湖北', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '广西', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '甘肃', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '山西', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '内蒙古', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '陕西', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '吉林', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '福建', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '贵州', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '广东', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '青海', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '西藏', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '四川', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '宁夏', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '海南', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '台湾', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '香港', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '澳门', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"}
//      ]
        var myChart = echarts.init(document.getElementById('main'));
        
        let option = {
            tooltip: {
            	show: true, // 是否显示
            	//triggerOn: "click",
            	padding: 10, // 提示框浮层内边距，
            	textStyle: { // 提示框浮层的文本样式。
                    color: '#3a385e',
                    fontStyle: 'normal',
                    fontWeight: 'bold',
                    fontFamily: 'Source Han Sans CN',
                    fontSize: 14,
                },
            	extraCssText: 'border: 1px solid #F1F6FC;box-shadow: 0px 3px 10px #EEF4FA; width: 230px;height:175px; background: #fff; border-radius: 8px;',
                formatter:function(params,ticket, callback){
                	//debugger
                	//console.log(params)
					if(params.name=="台湾"||params.name=="南海诸岛"||params.name=="香港"||params.name=="澳门"){
						return
					}
            		var areaSampling = params.data.areaSampling.substr(0,params.data.areaSampling.length-1);
            		var countSampling = params.data.countSampling.substr(0,params.data.countSampling.length-1);              	
                	var htmlStr = '<div style="text-align:center;font-family:Source Han Sans CN;">'+params.name+'</div>'+
                				'<div style="width:200px;border:1px solid #e7eaef;margin-top:4px;"></div>'+
	                				'<div style="margin-top:12px;">'+
									'<div style="display: inline-block;">'+
										'<div class="circleChart" id="areatip" ></div>'+
										'<div style="margin-top:9px;font-family:Source Han Sans CN;">已提交面积</div>'+
										'<div style="display:inline-block;font-size:14px;color:#107ce5;font-family:Source Han Sans CN;">'+params.data.value+'</div>'+
										'<span style="display:inline-block;font-size:12px;color:#6a798d;font-family:Source Han Sans CN;margin-left:2px;">万平方米</span>'+
									'</div>'+
									'<div style="display: inline-block;margin-left: 30px;">'+
										'<div class="circleChart" id="numstip" ></div>'+
										'<div style="margin-top:9px;font-family:Source Han Sans CN;">已提交数量</div>'+
										'<div style="display:inline-block;font-size:14px;color:#28c99d;font-family:Source Han Sans CN;">'+params.data.countData+'</div>'+
										'<span style="display:inline-block;font-size:12px;color:#6a798d;font-family:Source Han Sans CN;margin-left:2px;">栋</span>'+
									'</div>'+
								'</div>';

					setTimeout(function(){
						$(".circleChart#areatip").circleChart({
							color:"#1EB4FF",           
				            value: areaSampling,
				            lineCap:"square",
				            counterclockwise:true,
				            startAngle:25,
				            textSize:"14px",
				            size:66,
				            text: true,
				            text: params.data.areaSampling,
							redraw: false,
							textCenter: true,
//							onDraw: function(el, circle) {
//				                circle.text(Math.round(circle.value * 100) / 100 + "%");
//				            }
				       	});
				       	$(".circleChart#numstip").circleChart({
							color:"#28C99D",           
				            value: countSampling,
				            lineCap:"square",
				            counterclockwise:true,
				            startAngle:25,
				            textSize:"14px",
				            size:66,
				            text: true,
				            text: params.data.countSampling,
		            		textCenter: true,
							redraw: false,
							textCenter: true,
//							onDraw: function(el, circle) {
//				                circle.text(circle.value + "%");
//				            }
				       	});
					},0);
					
                	return htmlStr;
                    //return params.seriesName+'<br />'+params.name+'：'+params.value
                }//数据格式化
            },
//          visualMap: {
//              min: 0,
//              max: 150,
//              left: 'left',
//              top: 'bottom',
//              text: ['高','低'],//取值范围的文字
//              inRange: {
//                  color: ['#ffffff', '#7df8db']//取值范围的颜色
//              },
//              show:false//图注
//          },
            dataRange: {//左下角的颜色块。start：值域开始值；end：值域结束值；label：图例名称；color：自定义颜色值
                x: 'left',
                y: 'bottom',
                itemWidth: 30, // 值域图形宽度，线性渐变水平布局宽度为该值 * 10
	          	itemHeight: 20, // 值域图形高度，线性渐变垂直布局高度为该值 * 10
//				borderColor: "#6F7EA8",
//				borderWidth:1,
	          	itemGap: 10,
	          	padding: 10,
              	splitList: [
                    {start: 25, label: '> 25', color: '#7df8db'},
                    {start: 0, end: 25, label: '0 - 25', color: '#c8fdfd'},
                    {start:0, end: 0,label: '未开展工作', color: '#ffffff'}
          		],
          		textStyle: {
          			fontSize:'14',
					color: '#6a798d' // 值域文字颜色
				},
				selectedMode: false,
				show:false,
				//color: ['#E0022B', '#E09107', '#A3E00B']
            },

            geo: {
                map: 'china',
                roam: false,//不开启缩放和平移
                //center: [105.194115019531, 35.582111640625],
          		aspectScale: 0.75, //长宽比

                zoom:1.1,//视角缩放比例
                label: {
                    normal: {
                        show: true,
                        fontSize:'11',
                        color: 'rgba(0,0,0,0.7)'
                    }
                },
                itemStyle: {
                    normal:{
                        //borderColor: 'rgba(0, 0, 0, 0.2)',
                        borderColor: "#6F7EA8",
                        areaColor: "#F3B329",
                        shadowColor:"#454e69",
		                shadowOffsetX:0,
		                shadowOffsetY:10
                    },
                    // emphasis:{
                    //     areaColor: '#F3B329',//鼠标选择区域颜色
                    //     shadowOffsetX: 0,
                    //     shadowOffsetY: 0,
                    //     shadowBlur: 0,
                    //     borderWidth: 0,
                    //     shadowColor: 'rgba(0, 0, 0, 0.5)'
                    //     //shadowColor:"#01273F",
                    // }
                }
            },
            series : [
                {	
                	type: "map",
		            map: "china",
		            //center: [105.194115019531, 35.582111640625],
		            zoom:1.1,
		            geoIndex: 1,
		            aspectScale: 0.75, //长宽比
		            roam: false,
		            label: {
	                    normal: {
	                        show: true,
	                        fontSize:'11',
	                        color: 'rgba(0,0,0,0.7)'
	                    }
                	},
		            // emphasis:{
                    //     areaColor: '#F3B329',//鼠标选择区域颜色
                    //     shadowOffsetX: 20,
                    //     shadowOffsetY: 20,
                    //     shadowBlur: 20,
                    //     borderWidth: 0,
                    //     shadowColor: 'rgba(0, 0, 0, 0.5)'
                    // },
		            itemStyle: {
                      normal: {
                        //areaColor: "#013C62",
                        //shadowColor:"#01273F",
                        borderColor: "#6F7EA8",
                        //borderColor: 'rgba(0, 0, 0, 0.2)',
                        borderWidth: 1.2
                      },
                        emphasis:{
                            areaColor: '#F3B329',//鼠标选择区域颜色
                            shadowOffsetX: 20,
                            shadowOffsetY: 20,
                            shadowBlur: 20,
                            borderWidth: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        },
		            },
                    name: '信息量',
                 // type: 'map',
                 // geoIndex: 1,
                    data:dataList
                }
            ]
        };
        myChart.setOption(option);
        myChart.on('click', function (params) {
        	//debugger
            $("#main").hide();
            $("#province").show();
            $("#city").hide();
            $("#right-top").show();
            $("#backBtn1").show();
            $("#selectProvince").show();
            $("#backBtn2").hide();
            $(".right-main-title").text(params.data.districtName + "已提交房屋数据统计");
            $(".main-title").text(params.data.districtName + "已提交面积区划地图");
            $("#belongtoProvince").val(params.data.districtName);
            initSearchBlock(1,params.data.districtName);
            getStructure(1,params.data.districtName);
            createAreaGrid(1,params.data.districtName);
            createNumsGrid(1,params.data.districtName);
//          alert(params.name);
          	provinceMap(params.name,params.data.districtName);
            
        });

    };
    var provinceMap = function (name,province) {
    	//debugger;
    	var dataList;
		$.ajax({
            url: getCmController() + "division/cityFwData",
            contentType: "application/json",
            type: "get",
            async: false,
            data:{
            	province:province
            },
            success: function (data) {
                console.log(data)
                dataList = data;
            }
        })
//  	let dataList=[
//          {name: "德州市", value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '聊城市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '菏泽市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '滨州市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '济南市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '泰安市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '济宁市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '东营市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '淄博市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '莱芜市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '潍坊市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '临沂市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '枣庄市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '烟台市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '青岛市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '日照市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//          {name: '威海市', value: randomValue(),areaSampling: "78.96%",countSampling:"68.25%"},
//
//      ]
	    let provinceChart = echarts.init(document.getElementById('province'))
	    let option = {
	    	tooltip: {
	    		show: true, // 是否显示
            	//triggerOn: "click",
            	padding: 10, // 提示框浮层内边距，
            	textStyle: { // 提示框浮层的文本样式。
                    color: '#3a385e',
                    fontStyle: 'normal',
                    fontWeight: 'bold',
                    fontFamily: 'Source Han Sans CN',
                    fontSize: 14,
                },
            	extraCssText: 'border: 1px solid #F1F6FC;box-shadow: 0px 3px 10px #EEF4FA; width: 230px;height:175px; background: #fff; border-radius: 8px;',
                formatter:function(params,ticket, callback){
                    var areaSampling = params.data.areaSampling.substr(0,params.data.areaSampling.length-1);
                	var countSampling = params.data.countSampling.substr(0,params.data.countSampling.length-1);
                	var htmlStr = '<div style="text-align:center;font-family:Source Han Sans CN;">'+params.name+'</div>'+
                				'<div style="width:200px;border:1px solid #e7eaef;margin-top:4px;"></div>'+
	                				'<div style="margin-top:12px;">'+
									'<div style="display: inline-block;">'+
										'<div class="circleChart" id="areatip" ></div>'+
										'<div style="margin-top:9px;font-family:Source Han Sans CN;">已提交面积</div>'+
										'<div style="display:inline-block;font-size:14px;color:#107ce5;font-family:Source Han Sans CN;">'+params.data.value+'</div>'+
										'<span style="display:inline-block;font-size:12px;color:#6a798d;font-family:Source Han Sans CN;margin-left:2px;">万平方米</span>'+
									'</div>'+
									'<div style="display: inline-block;margin-left: 30px;">'+
										'<div class="circleChart" id="numstip" ></div>'+
										'<div style="margin-top:9px;font-family:Source Han Sans CN;">已提交数量</div>'+
										'<div style="display:inline-block;font-size:14px;color:#28c99d;font-family:Source Han Sans CN;">'+params.data.countData+'</div>'+
										'<span style="display:inline-block;font-size:12px;color:#6a798d;font-family:Source Han Sans CN;margin-left:2px;">栋</span>'+
									'</div>'+
								'</div>';
					setTimeout(function(){
						$(".circleChart#areatip").circleChart({
							color:"#1EB4FF",           
				            value: areaSampling,
				            lineCap:"square",
				            counterclockwise:true,
				            startAngle:25,
				            textSize:"14px",
				            size:66,
				            text: true,
				            text: params.data.areaSampling,
							redraw: false,
							textCenter: true,
//							onDraw: function(el, circle) {
//				                circle.text(Math.round(circle.value * 100) / 100 + "%");
//				            }
				       	});
				       	$(".circleChart#numstip").circleChart({
							color:"#28C99D",           
				            value: countSampling,
				            lineCap:"square",
				            counterclockwise:true,
				            startAngle:25,
				            textSize:"14px",
				            size:66,
				            text: true,
				            text: params.data.countSampling,
		            		textCenter: true,
							redraw: false,
							textCenter: true,
//							onDraw: function(el, circle) {
//				                circle.text(circle.value + "%");
//				            }
				       	});
					},0);
					
                	return htmlStr;
                }//数据格式化
            },
//          visualMap: {
//              min: 0,
//              max: 150,
//              left: 'left',
//              top: 'bottom',
//              text: ['高','低'],//取值范围的文字
//              inRange: {
//                  color: ['#ffffff', '#7df8db']//取值范围的颜色
//              },
//              show:false//图注
//          },
            dataRange: {//左下角的颜色块。start：值域开始值；end：值域结束值；label：图例名称；color：自定义颜色值
                x: 'left',
                y: 'bottom',
                itemWidth: 30, // 值域图形宽度，线性渐变水平布局宽度为该值 * 10
	          	itemHeight: 20, // 值域图形高度，线性渐变垂直布局高度为该值 * 10
//				borderColor: "#6F7EA8",
//				borderWidth:1,
	          	itemGap: 10,
	          	padding: 10,
              	splitList: [
                    {start: 25, label: '> 25', color: '#7df8db'},
                    {start: 0, end: 25, label: '0 - 25', color: '#c8fdfd'},
                    {start:0, end: 0,label: '未开展工作', color: '#ffffff'}
          		],
          		textStyle: {
          			fontSize:'14',
					color: '#6a798d' // 值域文字颜色
				},
				selectedMode: false,
				show:false,
				//color: ['#E0022B', '#E09107', '#A3E00B']
            },
            geo: {
                map: name, //这里的名称需要和shandong.js: echarts.registerMap('shandong',{})中的名称一致
                roam: false,//不开启缩放和平移
                zoom:1.2,//视角缩放比例
                aspectScale: 0.75, //长宽比
//              label: {
//                  normal: {
//                      show: true,
//                      fontSize:'12',
//                      color: 'rgba(0,0,0,0.7)'
//                  }
//              },
                itemStyle: {
                    normal:{
                        //borderColor: 'rgba(0, 0, 0, 0.2)',
                        borderColor: "#6F7EA8",
                        areaColor: "#01273F",
                        shadowColor:"#454e69",
		                shadowOffsetX:0,
		                shadowOffsetY:10
                    },
                    emphasis:{
                        areaColor: '#F3B329',//鼠标选择区域颜色
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        shadowBlur: 20,
                        borderWidth: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            },
            series : [
                {
                    name: '信息量',
                    type: 'map',
                    map: name, //这里的名称需要和shandong.js: echarts.registerMap('shandong',{})中的名称一致
                    zoom:1.2,
		            geoIndex: 1,
		            aspectScale: 0.75, //长宽比
		            roam: false,
		            label: {
	                    normal: {
	                        show: true,
	                        fontSize:'12',
	                        color: 'rgba(0,0,0,0.7)'
	                    }
                	},
		            // emphasis:{
                    //     areaColor: '#F3B329',//鼠标选择区域颜色
                    //     shadowOffsetX: 20,
                    //     shadowOffsetY: 20,
                    //     shadowBlur: 20,
                    //     borderWidth: 0,
                    //     shadowColor: 'rgba(0, 0, 0, 0.5)'
                    // },
		            itemStyle: {
                      normal: {
                        //areaColor: "#013C62",
                        //shadowColor:"#01273F",
                        borderColor: "#6F7EA8",
                        //borderColor: 'rgba(0, 0, 0, 0.2)',
                        borderWidth: 1.2
                      },
                        emphasis:{
                            areaColor: '#F3B329',//鼠标选择区域颜色
                            shadowOffsetX: 20,
                            shadowOffsetY: 20,
                            shadowBlur: 20,
                            borderWidth: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        },
		            },
                  	data:dataList
                }
            ]
	    }
	    provinceChart.setOption(option);
	    provinceChart.off('click');
	    provinceChart.on('click', function (params) {	    	
//          $("#main").hide();
//          $("#province").hide();
//          $("#city").show();
//          $("#backBtn1").hide();
//          $("#backBtn2").show();
            //alert(params.name)
            //cityMap(params.name);            
       });
  	}
	var cityMap = function(cityName){
	    var linyiMapChart = echarts.init(document.getElementById('city'))
	    echarts.registerMap(cityName, linyiMap, {})
	   	//echarts提供的方法echarts.registerMap(名称，地图数据，其他配置)
	    let option = {
	    	tooltip: {
                formatter:function(params,ticket, callback){
                    return params.seriesName+'<br />'+params.name+'：'+params.value
                }//数据格式化
            },
            visualMap: {
                min: 0,
                max: 1500,
                left: 'left',
                top: 'bottom',
                text: ['高','低'],//取值范围的文字
                inRange: {
                    color: ['#e0ffff', '#006edd']//取值范围的颜色
                },
                show:true//图注
            },
	      	series: [
		        {
	        		name: '信息量',
		          	type: 'map',
		          	mapType: cityName,//名称需要echarts.registerMap('linyi',linyiMap,{})中的名称一致
		          	label: { show: true }, //显示文字
		          	roam: false,
		          	geoIndex: 0,
		          	data: [],
		        },
	      	],
	    }
	    linyiMapChart.setOption(option)
		
	}

    // 导出
    var exportTask = function () {
        var buttons = [];
        buttons.push({
            name: '确定',
            callback: function () {
                //点击确定
                var formType = $("#formType").val();
                let startDate = $("#complex1").val();
                let endDate = $("#complex2").val();
                $.ajax({
                    url: getZwController() + "/isEmpty",
                    data: {
                        type: formType,
                        startDate: startDate,
                        endDate: endDate
                    },
                    type: "get",
                    success: function (data) {
                        console.log(data);
                        if (data.message == '否') {
                            window.location.href = getZwController() + "/export?type=" + formType+"&startDate="+startDate+"&endDate="+endDate;
                        } else if (data.message == '是') {
                            Util.alert('该类型数据数据为空，无法导出！');
                        } else {
                            // 未选择类型，请选择一种类型！
                            Util.alert(data.message);
                        }
                    }
                });
                dialog.hide();
            }
        });
        var dialog = Dialog({
            id: "viewTeamDialog",
            cache: false,
            title: '选择表单类型', //dialog标题
            width: "400px",
            height: "250px",
            body:
                '<div id="TeamGrid">' +
                    '<div class="col-md-12 form-horizontal">' +
                        '<div class="form-group">' +
                            '<label for="formType" class="col-md-4 control-label"> </span>表单类型:</label>' +
                            '<div class="col-md-8">' +
                                '<select class="form-control" id="formType" name="formType" >' +
                                    '<option value="" disabled selected style="display:none;">请选择</option>' +
                                    '<option value="0">城镇住宅</option>' +
                                    '<option value="1">城镇非住宅</option>' +
                                    '<option value="2">农村住房</option>' +
                                    '<option value="3">农村公共建筑</option>' +
                                '</select>' +
                            '</div>' +
                        '</div>' +
                        '<div class="form-group">' +
                            '<label for="formType" class="col-md-4 control-label"> </span>开始日期:</label>' +
                            '<div class="col-md-8">' +
                                '<div class="input-group">'+
                                    '<input id="complex1" type="text" class="form-control">'+
                                    '<a id="complex_del1" class="input-group-addon"><i class="fa fa-times"></i></a>'+
                                    '<a id="complex_show1" class="input-group-addon"><i class="fa fa-calendar"></i></a>'+
                                '</div>'+
                            '</div>' +
                        '</div>' +
                        '<div class="form-group">' +
                            '<label for="complex2" class="col-md-4 control-label"> </span>结束日期:</label>' +
                            '<div class="col-md-8">' +
                                '<div class="input-group">'+
                                    '<input id="complex2" type="text" class="form-control">'+
                                    '<a id="complex_del2" class="input-group-addon"><i class="fa fa-times"></i></a>'+
                                    '<a id="complex_show2" class="input-group-addon"><i class="fa fa-calendar"></i></a>'+
                                '</div>'+
                            '</div>' +
                        '</div>' +
                    '</div>' +
                '</div>',
            buttons: buttons,
            afterOpen: function () {
                dateComponent();
            }
        });
        dialog.show();
    }





    /*// 导出多个图片为zip格式
    var exportPicture = function () {
        var buttons = [];
        buttons.push({
            name: '确定',
            callback: function () {
                //点击确定
                var formType = $("#formType").val();
                let startDate = $("#complex1").val();
                let endDate = $("#complex2").val();
                let province = $("#province").val();
                $.ajax({
                    url: getZwController() + "/isEmpty",
                    data: {
                        type: formType,
                        startDate: startDate,
                        endDate: endDate,
                        province: province
                    },
                    type: "get",
                    success: function (data) {
                        console.log(data);
                        if (data.message == '否') {
                            window.location.href = getZwController() + "/downLoadZipFile?type="+formType+"&startDate="+startDate+"&endDate="+endDate+"&province="+province;
                        } else if (data.message == '是') {
                            Util.alert('该类型数据数据为空，无法导出！');
                        } else {
                            // 未选择类型，请选择一种类型！
                            Util.alert(data.message);
                        }
                    }
                });
                dialog.hide();
            }
        });
        var dialog = Dialog({
            id: "viewTeamDialog",
            cache: false,
            title: '选择表单类型', //dialog标题
            width: "400px",
            height: "250px",
            body:
                '<div id="TeamGrid">' +
                '<div class="col-md-12 form-horizontal">' +
                '<div class="form-group">' +
                '<label for="formType" class="col-md-4 control-label"> </span>表单类型:</label>' +
                '<div class="col-md-8">' +
                '<select class="form-control" id="formType" name="formType" >' +
                '<option value="" disabled selected style="display:none;">请选择</option>' +
                '<option value="0">城镇住宅</option>' +
                '<option value="1">城镇非住宅</option>' +
                '<option value="2">农村住房</option>' +
                '<option value="3">农村公共建筑</option>' +
                '</select>' +
                '</div>' +
                '</div>' +

                '<div class="form-group">' +
                '<label for="formType" class="col-md-4 control-label"> </span>开始日期:</label>' +
                '<div class="col-md-8">' +
                '<div class="input-group">'+
                '<input id="complex1" type="text" class="form-control">'+
                '<a id="complex_del1" class="input-group-addon"><i class="fa fa-times"></i></a>'+
                '<a id="complex_show1" class="input-group-addon"><i class="fa fa-calendar"></i></a>'+
                '</div>'+
                '</div>' +
                '</div>' +
                '<div class="form-group">' +
                '<label for="complex2" class="col-md-4 control-label"> </span>结束日期:</label>' +
                    '<div class="col-md-8">' +
                        '<div class="input-group">'+
                            '<input id="complex2" type="text" class="form-control">'+
                            '<a id="complex_del2" class="input-group-addon"><i class="fa fa-times"></i></a>'+
                            '<a id="complex_show2" class="input-group-addon"><i class="fa fa-calendar"></i></a>'+
                        '</div>'+
                    '</div>' +
                '</div>' +
                '<div class="form-group">' +
                '<label for="province" class="col-md-4 control-label"> </span>省份:</label>' +
                    '<div class="col-md-8">' +
                    '<select class="form-control" id="province" name="province" >' +
                        '<option value="" selected style="display:none;">请选择</option>' +
                    '</select>' +
                    '</div>' +
                '</div>' +

                '</div>' +
                '</div>',
            buttons: buttons,
            afterOpen: function () {
                // 日期组件
                dateComponent();
                onlyProvince()
            }
        });
        dialog.show();
    }
    // 导出图片-省控件
    var onlyProvince = function () {
        $.ajax({
            url: getServer() + "/fw/taskForm/user/division",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                if (data.message == '超级管理员') {
                    let html = "";
                    $.ajax({
                        url: "/app/divisions/root/subdivisions",
                        contentType: "application/json",
                        type: "get",
                        success: function (data) {
                            console.log(data);
                            $.each(data, function (idx, item) {
                                html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                            });
                            $("#province").append(html);
                        }
                    });
                } else {
                    var html = "<option value='" + data.divisionName + "' exid='" + data.divisionId + "'>" + data.divisionName + "</option>";
                    $("#province").append(html);
                    let divisionName = data.divisionName;
                    $("#province").val(divisionName);
                    $("#province").attr("disabled", true);
                }
            }
        });
    }*/

    // 日期组件
    var dateComponent = function () {
        require(["jquery", "Date", "DateCN", "css!DateCss"], function ($) {
            $("#complex1").datetimepicker({
                //设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
                language: "cn",
                //输出格式化
                format: 'yyyy-mm-dd',
                //直接选择‘今天’
                todayBtn: true,
                //设置最精确的时间选择视图
                minView: 'month',
                //高亮当天日期
                todayHighlight: true,
                //选择完毕后自动关闭
                autoclose: true
            });
            /* 删除按钮 */
            $("#complex_show1").on("click", function () {
                $('#complex1').datetimepicker('show');
            });
            /* 显示按钮 */
            $("#complex_del1").on("click", function () {
                $("#complex1").val("");
            });

            $("#complex2").datetimepicker({
                //设置使用语言：cn是自定义的中文版本，还可以扩展其他语言版本
                language: "cn",
                //输出格式化
                format: 'yyyy-mm-dd',
                //直接选择‘今天’
                todayBtn: true,
                //设置最精确的时间选择视图
                minView: 'month',
                //高亮当天日期
                todayHighlight: true,
                //选择完毕后自动关闭
                autoclose: true
            });
            /* 删除按钮 */
            $("#complex_show2").on("click", function () {
                $('#complex2').datetimepicker('show');
            });
            /* 显示按钮 */
            $("#complex_del2").on("click", function () {
                $("#complex2").val("");
            });
            // 时间大小规则
            $("#complex1").change(function () {
                if ($("#complex1").val() != "" && $("#complex2").val() != "") {
                    if ($("#complex1").val() > $("#complex2").val()) {
                        Util.alert("开始日期必须小于等于结束日期", function () {
                            $("#complex1").val("");
                            $("#complex2").val("");
                        });
                        return;
                    }
                }
            });
            $("#complex2").change(function () {
                if ($("#complex1").val() != "" && $("#complex2").val() != "") {
                    if ($("#complex1").val() > $("#complex2").val()) {
                        Util.alert("开始日期必须小于等于结束日期", function () {
                            $("#complex1").val("");
                            $("#complex2").val("");
                        });
                        return;
                    }
                }
            });
        })
    }






    // 初始化加载搜索框内容
    var initSearchForm = function () {
        //初始化行政岗区划
        var combotree = Combotree({
            // combo组件相关配置
            combo: {
                //要渲染的input的id
                id: "region",
                //下拉框的类型：单选or多选
                multi: false,
                key: {
                    idKey: "divisionId",
                    textKey: "divisionName"
                },
                //          placeholder: "请选择……",
                event: {
                    onShowPanel: function () {
                        console.log("show");
                    },
                    onHidePanel: function () {
                        console.log("hide");
                    },
                    onChange: function (n, o) {
                        $("#regionId").val(n[0].divisionId);
                        $("#region").val(n[0].divisionName);
                    }
                }
            },
            // ztree组件相关配置
            ztree: {
                data: {
                    simpleData: {
                        enable: true,
                        idKey: "divisionId", // 主键属性名
                        pIdKey: "parentId" // 父节点属性名
                    },
                    key: {
                        name: "divisionName" // 显示名称属性名
                    }
                },
                check: {
                    chkboxType: {
                        'Y': '',
                        'N': ''
                    }
                }
            },
            data: {
                url: getDivisionController() + 'initDivisionZtree',
                type: 'GET',
                success: function () {

                }
            },
            formatter: function (node) {
                node.open = true;
            },
            value: $("#divisionId").val(),
            search: {
                enable: true,
                fields: ["divisionName"]
            }
        });
    }

    // 超级管理员-省市县
    var province = function () {
        var html = "";
        $.ajax({
            url: "/app/divisions/root/subdivisions",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                $.each(data, function (idx, item) {
                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                });
                $("#belongtoProvince").append(html);
            }
        });
        // 点击省
        $("#belongtoProvince").change(function () {
            let divisionId = $(this).find("option:selected").attr("exid");
            let divisionName = $(this).find("option:selected").attr("value");

            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#belongtoCity option").remove();
            $("#belongtoCity").append(html);
            $("#belongtoArea option").remove();
            $("#belongtoArea").append(html);
            if ($(this).val() == "北京市" || $(this).val() == "天津市" || $(this).val() == "上海市" || $(this).val() == "重庆市") {
                $("#belongtoCity").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
                // 若是直辖市，直接退出此函数
                return;
            }
            $.ajax({
                url: "/app/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#belongtoCity").append(html);
                }
            });
        });
        // 点击市
        $("#belongtoCity").change(function () {
            if ($(this).val() == "") return;
            var html = '<option value="" disabled selected style="display:none;">请选择</option>';
            $("#belongtoArea option").remove();
            $("#belongtoArea").append(html);
            var divisionId = $(this).find("option:selected").attr("exid");
            $.ajax({
                url: "/app/divisions/" + divisionId + "/subdivisions",
                contentType: "application/json",
                type: "get",
                success: function (data) {
                    $.each(data, function (idx, item) {
                        html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                    });
                    $("#belongtoArea").append(html);
                }
            });
        });
    }

    // 重置省市县
    var resetDivision = function(){
        let html = '<option value="" disabled selected style="display:none;">请选择</option>';
        $("#belongtoProvince").val("");
        $("#belongtoCity").html(html);
        $("#belongtoArea").html(html);
    }


    // 初始化搜索栏省市区
    var initDivision = function () {
        $.ajax({
            url: getServer() + "/fw/taskForm/user/division",
            contentType: "application/json",
            type: "get",
            success: function (data) {
                if (data.message == '超级管理员') {
                    province();
                } else {
                    var html = "<option value='" + data.divisionName + "' exid='" + data.divisionId + "'>" + data.divisionName + "</option>";
                    $("#belongtoProvince").append(html);

                    // 点击省
                    $("#belongtoProvince").change(function () {
                        let divisionId = $(this).find("option:selected").attr("exid");
                        let divisionName = $(this).find("option:selected").attr("value");

                        var html = '<option value="" disabled selected style="display:none;">请选择</option>';
                        $("#belongtoCity option").remove();
                        $("#belongtoCity").append(html);
                        console.log(divisionId);
                        console.log(divisionName);
                        if ($(this).val() == "北京市" || $(this).val() == "天津市" || $(this).val() == "上海市" || $(this).val() == "重庆市") {
                            $("#belongtoCity").append("<option value='" + $(this).val() + "' exid='" + divisionId + "'>" + $(this).val() + "</option>");
                            // 若是直辖市，直接退出此函数
                            return;
                        }
                        $.ajax({
                            url: "/app/divisions/" + divisionId + "/subdivisions",
                            contentType: "application/json",
                            type: "get",
                            success: function (data) {
                                $.each(data, function (idx, item) {
                                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                });
                                $("#belongtoCity").append(html);
                            }
                        });
                    });
                    // 点击市
                    $("#belongtoCity").change(function () {
                        if ($(this).val() == "") return;
                        var html = '<option value="" disabled selected style="display:none;">请选择</option>';
                        $("#belongtoArea option").remove();
                        $("#belongtoArea").append(html);
                        var divisionId = $(this).find("option:selected").attr("exid");
                        $.ajax({
                            url: "/app/divisions/" + divisionId + "/subdivisions",
                            contentType: "application/json",
                            type: "get",
                            success: function (data) {
                                $.each(data, function (idx, item) {
                                    html += "<option value='" + item.divisionName + "' exid='" + item.divisionId + "'>" + item.divisionName + "</option>";
                                });
                                $("#belongtoArea").append(html);
                            }
                        });
                    });

                }
                
            }
        });
    }


    return {
        init: init
    };
});
